package com.yidu.t299.dao.ljc;
import com.yidu.t299.domain.ljc.Stockcopy;
import org.apache.ibatis.annotations.*;
import java.util.List;

/**
 * @author 刘建常
 * @version 1.0
 * @description
 * @date:2023/3/8 10:19
 */
@Mapper
public interface StockcopyMapper {
    /**
     * 增加
     * @param record
     * @return
     */
    @Insert({
            "insert into input_stock_copy (input_stock_id, author,publishing_company,textbook_name,provider,input_stock_relation,input_stock_time,textbook_price,input_stock_num,record_id)" +
                    " values " +
                    "(#{inputStockId,jdbcType=INTEGER}, #{author,jdbcType=VARCHAR}," +
                    "#{publishingCompany,jdbcType=VARCHAR},#{textbookName,jdbcType=VARCHAR}," +
                    "#{provider,jdbcType=VARCHAR},#{inputStockRelation,jdbcType=VARCHAR}," +
                    "#{inputStockTime,jdbcType=VARCHAR},#{textbookPrice,jdbcType=VARCHAR}," +
                    "#{inputStockNum,jdbcType=INTEGER},#{recordId,jdbcType=INTEGER})"
    })
    int insert(Stockcopy record);

    /**
     * 删除
     * @param inputStockId
     * @return
     */
    @Delete({
            "delete from input_stock_copy" +
                    " where input_stock_id = #{inputStockId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer inputStockId);

    /**
     * 修改
     * @param record
     * @return
     */
    @Update({
            "update input_stock_copy"+
            " set author = #{author,jdbcType=VARCHAR},"+
                    " publishing_company = #{publishingCompany,jdbcType=VARCHAR},"+
                    " textbook_name = #{textbookName,jdbcType=VARCHAR},"+
                    " provider = #{provider,jdbcType=VARCHAR},"+
                    " input_stock_relation = #{inputStockRelation,jdbcType=VARCHAR},"+
                    " input_stock_time = #{inputStockTime,jdbcType=VARCHAR},"+
                    " textbook_price = #{textbookPrice,jdbcType=VARCHAR},"+
                    " input_stock_num = #{inputStockNum,jdbcType=INTEGER},"+
                    " record_id = #{recordId,jdbcType=INTEGER}"+
                    " where input_stock_id = #{inputStockId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Stockcopy record);

    /**
     * 根据编号查询信息
     * @param inputStockId
     * @return
     */
    @Select({
            "select" +
                    " input_stock_id,author,publishing_company,textbook_name,provider,input_stock_relation," +
                    " input_stock_time,textbook_price,input_stock_num,record_id" +
                    " from input_stock_copy" +
                    " where input_stock_id = #{inputStockId,jdbcType=INTEGER}"
    })
    @Results(id = "StockcopyMap",value = {
            @Result(id = true,column = "input_stock_id",property = "inputStockId"),
            @Result(column = "author",property = "author"),
            @Result(column = "textbook_name",property = "textbookName"),
            @Result(column = "provider",property = "provider"),
            @Result(column = "input_stock_relation",property = "inputStockRelation"),
            @Result(column = "input_stock_time",property = "inputStockTime"),
            @Result(column = "textbook_price",property = "textbookPrice"),
            @Result(column = "input_stock_num",property = "inputStockNum"),
            @Result(column = "record_id",property = "recordId"),
            @Result(column = "publishing_company",property = "publishingCompany")
    })
    Stockcopy selectByPrimaryKey(Integer inputStockId);

    /**
     * 分页查询数据信息
     * @param rows
     * @param page
     * @param condition
     * @return
     */
    @Select("select * from input_stock_copy where 1=1 ${condition} limit #{page},#{rows}")
    @ResultMap("StockcopyMap")
    List<Stockcopy> selectByPage(@Param("rows") int rows, @Param("page") int page, @Param("condition") String condition);

    /**
     * 条件查询数据
     * @param condition
     * @return
     */
    @Select("select count(*) from input_stock_copy where 1=1 ${condition}")
    int selectCount(@Param("condition") String condition);

}
